import { useIntersectionObserver } from '@vueuse/core'
import {install} from "element-plus";

export const lazyPlugin =  {
    install(app){
        // 全局指令
        app.directive('img-lazy', {
            mounted(el, binding) {
                const {stop} = useIntersectionObserver(
                    el,
                    ([{ isIntersecting }], observerElement) => {
                        if(isIntersecting){
                            el.src = binding.value
                            stop()
                        }
                    }
                )
            }
        })
    }

}